﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="SortParam.cs" company="Collaboris Ltd.">
//   Copyright (c) Collaboris Ltd. All rights Reserved.
// </copyright>
// <summary>
//   The sort param.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Collaboris.DataAccess
{
    #region Imports

    using System.Collections.Generic;

    #endregion

    /// <summary>
    /// The sort param.
    /// </summary>
    public class SortParam
    {
        #region [rgn] Fields (2)

        /// <summary>
        /// The _direction.
        /// </summary>
        private SortOperator _direction = SortOperator.Asc;

        #endregion [rgn]

        #region [rgn] Constructors (1)

        /// <summary>
        /// Initializes a new instance of the <see cref="SortParam"/> class.
        /// </summary>
        /// <param name="fieldName">
        /// The field name.
        /// </param>
        /// <param name="direction">
        /// The direction.
        /// </param>
        public SortParam(string fieldName, SortOperator direction)
        {
            this.OrderByField = fieldName;
            this._direction = direction;
        }

        #endregion [rgn]

        #region [rgn] Properties (2)

        /// <summary>
        /// Gets or sets Direction.
        /// </summary>
        public SortOperator Direction
        {
            get
            {
                return this._direction;
            }

            set
            {
                this._direction = value;
            }
        }

        /// <summary>
        /// Gets or sets OrderByField.
        /// </summary>
        public string OrderByField
        {
            get;
            set;
        }

        #endregion [rgn]
    }

    /// <summary>
    /// List of sorting parameters
    /// </summary>
    public class SortParamCollection : List<SortParam>
    {
        #region [rgn] Methods (1)

        // [rgn] Public Methods (1)

        /// <summary>
        /// The add.
        /// </summary>
        /// <param name="fieldName">
        /// The field name.
        /// </param>
        /// <param name="direction">
        /// The direction.
        /// </param>
        public void Add(string fieldName, SortOperator direction)
        {
            var param = new SortParam(fieldName, direction);
            this.Add(param);
        }

        #endregion [rgn]
    }
}